# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=dynamips
pkgver=0.2.23
pkgrel=1
pkgdesc="Cisco router emulator"
url="https://github.com/GNS3/dynamips"
# x86:
# common/ppc32_x86_trans.h:63:4: error: 'asm' operand has impossible constraints
#    63 |    asm volatile ("movl %0,%%edi"::"r"(cpu):
arch="all !x86"
license="GPL-2.0"
makedepends="cmake libpcap-dev elfutils-dev linux-headers libnsl-dev samurai"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/GNS3/dynamips/archive/v$pkgver.tar.gz"
options="!check" # no tests

prepare() {
	sed -e "s:^set ( DYNAMIPS_FLAGS:#&:" -i cmake/dependencies.cmake
	default_prepare
}

build() {
	if [ "$CARCH" = "x86_64" ]; then
		export DYNAMIPS_ARCH=amd64
	fi
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
b68af39cd66f10555d860437f55e63887aefdb5a949bacacf3a308cc0c4eaaab3bb9a496c5ac32fd19d3920bada807bff2af8eb66b01d8d735419fec5d134746  dynamips-0.2.23.tar.gz
"
